<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>系统日志</title>
    <script type="text/javascript">
      Ext.onReady(function(){
        //----------------------------------------------------------------------
        var sysLogDS = new Ext.data.Store({
          paramNames: {
            start: "start",
            limit: "limit"
          },
          baseParams: {
            start: 0,
            limit: pageSize + 10
          },
          proxy: new Ext.data.HttpProxy({
            url: '/log/getAllSysLog'
          }),
          reader: new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
          }, [{
              name: 'id'
            }, {
              name: 'c_name'
            }, {
              name: 'a_name'
            }, {
              name: 'description'
            },{
              name: 'created_at'
            }])
        });

        //生成入库Grid的CM
        var sysLogSM = new Ext.grid.CheckboxSelectionModel({singleSelect:true});
        var sysLogCM = new Ext.grid.ColumnModel({defaults: {
            sortable: true,
            menuDisabled: false
          },columns:[new Ext.grid.RowNumberer({width: 30}),sysLogSM,{
              id: 'common',
              header: 'DB',
              dataIndex: 'id',
              width: 50
            },{
              header: '控制器',
              dataIndex: 'c_name',
              width: 100
            },{
              header: '方法',
              dataIndex: 'a_name',
              width: 210
            },{
              header: '信息',
              dataIndex: 'description',
              width: 750
            },{
              header: '日期',
              dataIndex: 'created_at',
              renderer: Ext.util.Format.dateRenderer('Y-m-d H:i'),
              width: 110
            }
          ]});

        //生成要订单的产品的Grid
        var sysLogGrid = new Ext.grid.GridPanel({
          title:'系统日志列表',
          store: sysLogDS,
          cm: sysLogCM,
          sm: sysLogSM,
          width: screenWidth-155,
          height: screenHeight-345,
          frame: true,
          tbar: [{
              text: '删除',
              iconCls: 'remove',
              handler : function(){
                var record = sysLogSM.getSelected;
                if (!record) {
                  return false;
                }
                sysLogDS.remove(record);
              }
            }],
          bbar: new Ext.PagingToolbar({
            pageSize: 20,
            store: sysLogDS,
            displayInfo: true,
            displayMsg: "显示第 {0} 条到 {1} 条记录，一共 {2} 条",
            emptyMsg: "没有记录"
          })
        });
        sysLogDS.load();

        sysLogGrid.on('rowdblclick', function(gridPanel, rowIndex, e){
          description.setValue(sysLogDS.getAt(rowIndex).get('description'));
        });

        var description = new Ext.form.TextArea({
          fieldLabel: '错误详细内容',
          name: 'description',
          allowBlank: false,
          height: 160,
          width: screenWidth-155
        });

        //总的panel
        var workbenchPanel = new Ext.Panel({
          width: screenWidth-155,
          height: screenHeight-170,
          frame:false,
          layout:'table',
          layoutConfig: {columns:1},
          defaults:{margins:'5 5 5 5'},
          items:[sysLogGrid,description]
        });
        workbenchPanel.render("sys_log_list");
      })
    </script>
  </head>
  <body>
    <div id="sys_log_list"></div>
  </body>
</html>
